import { DatabaseType } from '@/lib/domain/database-type';
import type { Template } from '../templates-data';
import image from '@/assets/templates/doorkeeper-db.png';
import imageDark from '@/assets/templates/doorkeeper-db-dark.png';

export const doorkeeperDb: Template = {
    slug: 'doorkeeper-database',
    name: 'Doorkeeper',
    shortDescription: 'Rails OAuth 2 provider',
    description: 'Doorkeeper is an OAuth 2 provider for Ruby on Rails / Grape.',
    image,
    imageDark,
    tags: ['MySQL', 'Open Source', 'Rails'],
    featured: true,
    url: 'https://github.com/doorkeeper-gem/doorkeeper',
    diagram: {
        id: 'doorkeeper_db',
        name: 'doorkeeper-database',
        createdAt: new Date(),
        updatedAt: new Date(),
        databaseType: DatabaseType.MYSQL,
        tables: [
            {
                id: '5s9fctsmmsy96rgwxx22yxv5p',
                name: 'oauth_applications',
                schema: 't_doorkeeper_db',
                x: 100,
                y: 100,
                fields: [
                    {
                        id: '9w3uwcorjanaccb1tljxcris9',
                        name: 'id',
                        type: {
                            id: 'bigint',
                            name: 'bigint',
                        },
                        primaryKey: true,
                        unique: true,
                        nullable: false,
                        createdAt: Date.now(),
                    },
                    {
                        id: '8w3g80lo0tw7p3t06b5r9lg2o',
                        name: 'name',
                        type: {
                            id: 'varchar',
                            name: 'varchar',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: false,
                        collation: 'utf8mb4_0900_ai_ci',
                        createdAt: Date.now(),
                    },
                    {
                        id: 'uf3kgxkstwmiuezmvcnj847uj',
                        name: 'uid',
                        type: {
                            id: 'varchar',
                            name: 'varchar',
                        },
                        primaryKey: false,
                        unique: true,
                        nullable: false,
                        collation: 'utf8mb4_0900_ai_ci',
                        createdAt: Date.now(),
                    },
                    {
                        id: '5n63c3tsqzdvftkjnkq6i7k39',
                        name: 'secret',
                        type: {
                            id: 'varchar',
                            name: 'varchar',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: false,
                        collation: 'utf8mb4_0900_ai_ci',
                        createdAt: Date.now(),
                    },
                    {
                        id: 'cau4z0n2m8mcli9hx6ed64hyu',
                        name: 'redirect_uri',
                        type: {
                            id: 'text',
                            name: 'text',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: false,
                        collation: 'utf8mb4_0900_ai_ci',
                        createdAt: Date.now(),
                    },
                    {
                        id: 'fbagrcvuk25uzwq5unm991881',
                        name: 'scopes',
                        type: {
                            id: 'varchar',
                            name: 'varchar',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: false,
                        collation: 'utf8mb4_0900_ai_ci',
                        createdAt: Date.now(),
                    },
                    {
                        id: 'urzv1fn66dprx7tww1s0dsef8',
                        name: 'confidential',
                        type: {
                            id: 'tinyint',
                            name: 'tinyint',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: false,
                        createdAt: Date.now(),
                    },
                    {
                        id: 'mi7liyvghjixoawtdkic7ooot',
                        name: 'created_at',
                        type: {
                            id: 'datetime',
                            name: 'datetime',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: false,
                        createdAt: Date.now(),
                    },
                    {
                        id: 'bpuk51a0g725c9m6s6aedabfp',
                        name: 'updated_at',
                        type: {
                            id: 'datetime',
                            name: 'datetime',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: false,
                        createdAt: Date.now(),
                    },
                ],
                indexes: [
                    {
                        id: 'hw3xm9sv6fhy2wvz2orna1e3c',
                        name: 'oauth_applications_uid_unique',
                        unique: true,
                        fieldIds: ['uf3kgxkstwmiuezmvcnj847uj'],
                        createdAt: Date.now(),
                    },
                    {
                        id: 'ddbuj2dtx28emv9g9jv2inh7c',
                        name: 'PRIMARY',
                        unique: true,
                        fieldIds: ['9w3uwcorjanaccb1tljxcris9'],
                        createdAt: Date.now(),
                    },
                ],
                color: '#4dee8a',
                isView: false,
                isMaterializedView: false,
                createdAt: Date.now(),
            },
            {
                id: 'niw9mkgqx819etmpvu63dslic',
                name: 'oauth_access_tokens',
                schema: 't_doorkeeper_db',
                x: 562.4237256719184,
                y: -53.88174235403156,
                fields: [
                    {
                        id: 'rzwnbomoljnap72wvxaht5rjj',
                        name: 'id',
                        type: {
                            id: 'bigint',
                            name: 'bigint',
                        },
                        primaryKey: true,
                        unique: true,
                        nullable: false,
                        createdAt: Date.now(),
                    },
                    {
                        id: 'svcycxxruofrbl7ih2f27tl6s',
                        name: 'resource_owner_id',
                        type: {
                            id: 'bigint',
                            name: 'bigint',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: true,
                        createdAt: Date.now(),
                    },
                    {
                        id: 'ue57b6hukq4u6k2jggpdp4j40',
                        name: 'application_id',
                        type: {
                            id: 'bigint',
                            name: 'bigint',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: false,
                        createdAt: Date.now(),
                    },
                    {
                        id: 'gftvctnnukb8hab10vvd4sqz1',
                        name: 'token',
                        type: {
                            id: 'varchar',
                            name: 'varchar',
                        },
                        primaryKey: false,
                        unique: true,
                        nullable: false,
                        collation: 'utf8mb4_0900_ai_ci',
                        createdAt: Date.now(),
                    },
                    {
                        id: 'stus1int8xzwz31tdpamnrf3j',
                        name: 'refresh_token',
                        type: {
                            id: 'varchar',
                            name: 'varchar',
                        },
                        primaryKey: false,
                        unique: true,
                        nullable: true,
                        collation: 'utf8mb4_0900_ai_ci',
                        createdAt: Date.now(),
                    },
                    {
                        id: 'gc4a8icklv4k715kjo1nfgdqh',
                        name: 'expires_in',
                        type: {
                            id: 'int',
                            name: 'int',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: true,
                        createdAt: Date.now(),
                    },
                    {
                        id: 'bt6g2e2es9autp4s4lsf6o7mw',
                        name: 'revoked_at',
                        type: {
                            id: 'datetime',
                            name: 'datetime',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: true,
                        createdAt: Date.now(),
                    },
                    {
                        id: 'm74coxh0sval57vl85xfhldyx',
                        name: 'created_at',
                        type: {
                            id: 'datetime',
                            name: 'datetime',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: false,
                        createdAt: Date.now(),
                    },
                    {
                        id: 'hs91n9coj97l1agtcvjz3s5g0',
                        name: 'scopes',
                        type: {
                            id: 'varchar',
                            name: 'varchar',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: true,
                        collation: 'utf8mb4_0900_ai_ci',
                        createdAt: Date.now(),
                    },
                    {
                        id: 'mggpvfqw8zig20mh1ozjjkvoo',
                        name: 'previous_refresh_token',
                        type: {
                            id: 'varchar',
                            name: 'varchar',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: false,
                        collation: 'utf8mb4_0900_ai_ci',
                        createdAt: Date.now(),
                    },
                ],
                indexes: [
                    {
                        id: 'w1y0kvftt0yd0tph3g70onl3w',
                        name: 'oauth_access_tokens_application_id_index',
                        unique: false,
                        fieldIds: ['ue57b6hukq4u6k2jggpdp4j40'],
                        createdAt: Date.now(),
                    },
                    {
                        id: '2l2mh5fi238cp5ec2kqks3mlq',
                        name: 'oauth_access_tokens_refresh_token_unique',
                        unique: true,
                        fieldIds: ['stus1int8xzwz31tdpamnrf3j'],
                        createdAt: Date.now(),
                    },
                    {
                        id: 'n9yxzigeawx10z6tc5b1v2qjw',
                        name: 'oauth_access_tokens_resource_owner_id_index',
                        unique: false,
                        fieldIds: ['svcycxxruofrbl7ih2f27tl6s'],
                        createdAt: Date.now(),
                    },
                    {
                        id: 'y2al3g85a3nm8dfpjvoyy6ub1',
                        name: 'oauth_access_tokens_token_unique',
                        unique: true,
                        fieldIds: ['gftvctnnukb8hab10vvd4sqz1'],
                        createdAt: Date.now(),
                    },
                    {
                        id: 'q9j0ei3gd01c0agykvrpa9si5',
                        name: 'PRIMARY',
                        unique: true,
                        fieldIds: ['rzwnbomoljnap72wvxaht5rjj'],
                        createdAt: Date.now(),
                    },
                ],
                color: '#c05dcf',
                isView: false,
                isMaterializedView: false,
                createdAt: Date.now(),
            },
            {
                id: 'y45hybx72gu835y6me5xkxf3l',
                name: 'users',
                schema: 't_doorkeeper_db',
                x: 920.3240037071362,
                y: 278.5608897126969,
                fields: [
                    {
                        id: 'zwnnses125v9idekkxtvbsh1k',
                        name: 'id',
                        type: {
                            id: 'bigint',
                            name: 'bigint',
                        },
                        primaryKey: true,
                        unique: true,
                        nullable: false,
                        createdAt: Date.now(),
                    },
                ],
                indexes: [
                    {
                        id: 'qnb9vqcrl10cuucbvgbxpwrql',
                        name: 'PRIMARY',
                        unique: true,
                        fieldIds: ['zwnnses125v9idekkxtvbsh1k'],
                        createdAt: Date.now(),
                    },
                ],
                color: '#ffe374',
                isView: false,
                isMaterializedView: false,
                createdAt: Date.now(),
            },
            {
                id: 'zl0f5zdujwq39p02yiun3swnx',
                name: 'oauth_access_grants',
                schema: 't_doorkeeper_db',
                x: 442.0367006487488,
                y: 400.5049119555143,
                fields: [
                    {
                        id: '0dc4bf0xklltcexsnudn87858',
                        name: 'id',
                        type: {
                            id: 'bigint',
                            name: 'bigint',
                        },
                        primaryKey: true,
                        unique: true,
                        nullable: false,
                        createdAt: Date.now(),
                    },
                    {
                        id: 'n0dx2nbwesk4f4eayc5fow4rf',
                        name: 'resource_owner_id',
                        type: {
                            id: 'bigint',
                            name: 'bigint',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: false,
                        createdAt: Date.now(),
                    },
                    {
                        id: '3usgqxo8mc0vzf2d59j4c52mq',
                        name: 'application_id',
                        type: {
                            id: 'bigint',
                            name: 'bigint',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: false,
                        createdAt: Date.now(),
                    },
                    {
                        id: 'n9hn8jduqs3fy0iqtirgmsc0u',
                        name: 'token',
                        type: {
                            id: 'varchar',
                            name: 'varchar',
                        },
                        primaryKey: false,
                        unique: true,
                        nullable: false,
                        collation: 'utf8mb4_0900_ai_ci',
                        createdAt: Date.now(),
                    },
                    {
                        id: 'v5k2owfedw5bkx2myi5l3n5eh',
                        name: 'expires_in',
                        type: {
                            id: 'int',
                            name: 'int',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: false,
                        createdAt: Date.now(),
                    },
                    {
                        id: 'f9rji11u4corji12t0cn0tz9z',
                        name: 'redirect_uri',
                        type: {
                            id: 'text',
                            name: 'text',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: false,
                        collation: 'utf8mb4_0900_ai_ci',
                        createdAt: Date.now(),
                    },
                    {
                        id: '3dfb97ysllt65qd9azbfeh4ob',
                        name: 'created_at',
                        type: {
                            id: 'datetime',
                            name: 'datetime',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: false,
                        createdAt: Date.now(),
                    },
                    {
                        id: 'zols5jkofvt77wgd18tolgidv',
                        name: 'revoked_at',
                        type: {
                            id: 'datetime',
                            name: 'datetime',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: true,
                        createdAt: Date.now(),
                    },
                    {
                        id: '3nhab9g21hhnslze7pkbaojh8',
                        name: 'scopes',
                        type: {
                            id: 'varchar',
                            name: 'varchar',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: false,
                        collation: 'utf8mb4_0900_ai_ci',
                        createdAt: Date.now(),
                    },
                ],
                indexes: [
                    {
                        id: 'ldbno34wq68oog6ngy6gtzauu',
                        name: 'oauth_access_grants_application_id_index',
                        unique: false,
                        fieldIds: ['3usgqxo8mc0vzf2d59j4c52mq'],
                        createdAt: Date.now(),
                    },
                    {
                        id: '4qglx7v8h6pye1qh4e5ibqvyi',
                        name: 'oauth_access_grants_resource_owner_id_index',
                        unique: false,
                        fieldIds: ['n0dx2nbwesk4f4eayc5fow4rf'],
                        createdAt: Date.now(),
                    },
                    {
                        id: 'krd01ebul7w0z1us7irdcjyry',
                        name: 'oauth_access_grants_token_unique',
                        unique: true,
                        fieldIds: ['n9hn8jduqs3fy0iqtirgmsc0u'],
                        createdAt: Date.now(),
                    },
                    {
                        id: '6s2ssgczw5qfa0cnh5nk2t6h9',
                        name: 'PRIMARY',
                        unique: true,
                        fieldIds: ['0dc4bf0xklltcexsnudn87858'],
                        createdAt: Date.now(),
                    },
                ],
                color: '#ff9f74',
                isView: false,
                isMaterializedView: false,
                createdAt: Date.now(),
            },
        ],
        relationships: [
            {
                id: 'cnv6nm63754yl29dq9w3cbnwg',
                name: 'oauth_access_tokens_resource_owner_id_foreign',
                sourceSchema: 't_doorkeeper_db',
                targetSchema: 't_doorkeeper_db',
                sourceTableId: 'niw9mkgqx819etmpvu63dslic',
                targetTableId: 'y45hybx72gu835y6me5xkxf3l',
                sourceFieldId: 'svcycxxruofrbl7ih2f27tl6s',
                targetFieldId: 'zwnnses125v9idekkxtvbsh1k',
                sourceCardinality: 'many',
                targetCardinality: 'one',
                createdAt: Date.now(),
            },
            {
                id: 'eod8ieflqxcyeoi8xp1rkc6nm',
                name: 'oauth_access_grants_resource_owner_id_foreign',
                sourceSchema: 't_doorkeeper_db',
                targetSchema: 't_doorkeeper_db',
                sourceTableId: 'zl0f5zdujwq39p02yiun3swnx',
                targetTableId: 'y45hybx72gu835y6me5xkxf3l',
                sourceFieldId: 'n0dx2nbwesk4f4eayc5fow4rf',
                targetFieldId: 'zwnnses125v9idekkxtvbsh1k',
                sourceCardinality: 'many',
                targetCardinality: 'one',
                createdAt: Date.now(),
            },
            {
                id: 'nr99xikuvarwxnw5oxh1ahlzk',
                name: 'oauth_access_grants_application_id_foreign',
                sourceSchema: 't_doorkeeper_db',
                targetSchema: 't_doorkeeper_db',
                sourceTableId: 'zl0f5zdujwq39p02yiun3swnx',
                targetTableId: '5s9fctsmmsy96rgwxx22yxv5p',
                sourceFieldId: '3usgqxo8mc0vzf2d59j4c52mq',
                targetFieldId: '9w3uwcorjanaccb1tljxcris9',
                sourceCardinality: 'many',
                targetCardinality: 'one',
                createdAt: Date.now(),
            },
            {
                id: 'rv73p4hzcmpochd0gij75v4c9',
                name: 'oauth_access_tokens_application_id_foreign',
                sourceSchema: 't_doorkeeper_db',
                targetSchema: 't_doorkeeper_db',
                sourceTableId: 'niw9mkgqx819etmpvu63dslic',
                targetTableId: '5s9fctsmmsy96rgwxx22yxv5p',
                sourceFieldId: 'ue57b6hukq4u6k2jggpdp4j40',
                targetFieldId: '9w3uwcorjanaccb1tljxcris9',
                sourceCardinality: 'many',
                targetCardinality: 'one',
                createdAt: Date.now(),
            },
        ],
        dependencies: [],
    },
};
